from django.db import models


# 后台路由菜单
class Menu(models.Model):
    name = models.CharField(max_length=32, null=True, blank=True, verbose_name='菜单名称')
    is_menu = models.BooleanField(default=False, verbose_name='是否为菜单 1是 0不是')
    is_route = models.BooleanField(default=False, verbose_name='是否为路由 1是 0不是')
    path = models.CharField(max_length=255, null=True, blank=True, verbose_name='前端路由地址')
    urls = models.CharField(max_length=255, null=True, blank=True, verbose_name='api路由地址')
    method = models.CharField(max_length=10, null=True, blank=True, choices=(
        ('GET', 'GET'),
        ('POST', 'POST'),
        ('PUT', 'PUT'),
        ('DELETE', 'DELETE'),
        ('HEAD', 'HEAD'),
        ('CONNECT', 'CONNECT'),
        ('OPTIONS', 'OPTIONS'),
        ('TRACE', 'TRACE')
    ), verbose_name='请求方式')
    component = models.CharField(max_length=255, null=True, blank=True, verbose_name='模块')
    title = models.CharField(max_length=32, verbose_name='标题')
    icon = models.CharField(max_length=32, null=True, blank=True, verbose_name='图标')
    ord = models.PositiveIntegerField(default=0, verbose_name='排序')
    is_delete = models.BooleanField(default=False, verbose_name='是否删除 1删除 0正常')
    pid = models.PositiveIntegerField(default=0, verbose_name='父级')

    class Meta:
        db_table = 'zeus_menu'
        verbose_name = '菜单'
        verbose_name_plural = verbose_name

        def __str__(self):
            return self.name
